package com.huike.web.controller.report;


import com.huike.report.domain.vo.DragonTigerList;
import com.huike.common.utils.SecurityUtils;
import com.huike.report.domain.vo.IndexTodayInfoVO;
import com.huike.report.domain.vo.IndexTodoInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;

    /**
     * 首页--线索转化龙虎榜接口
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/salesStatistic")
    public AjaxResult getsalesStatistic(String beginCreateTime,String endCreateTime){
        List<DragonTigerList> list=reportService.getsalesStatistics(beginCreateTime,endCreateTime);
        return AjaxResult.success(list);
    }


    /**
     * 首页--商机转化龙虎榜接口
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(String beginCreateTime,String endCreateTime){
         List<DragonTigerList> list=reportService.businessChangeStatistics(beginCreateTime,endCreateTime);
         return AjaxResult.success(list);
    }

    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }


    /**
     * 首页--今日简报
     * @return
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo(){
        String username = SecurityUtils.getUsername();
        String now = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        IndexTodayInfoVO todayInfo = reportService.getTodayInfo(username, now);
        return AjaxResult.success(todayInfo);
    }

    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(String beginCreateTime,String endCreateTime) {
        String username = SecurityUtils.getUsername();
        IndexTodoInfoVO todoInfo = reportService.getTodoInfo(username, beginCreateTime, endCreateTime);
        return AjaxResult.success(todoInfo);
    }


}